<html>
<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<title>聊天记录</title>
	<script src="{{.Prefix}}/static/jquery.min.js"></script>
</head>
<body>
<div id="maindiv" style="margin:0 auto;max-width:800px;">
	<div>
	<b>关键字：</b><input type="text" id="searchWord"/>
	<input type="button" value="搜索" onclick="searchHistory();"/>
	<b>只支持一个单词！</b><br/>
<b>聊天室：<select id="chatroom" onchange="gotoPage(0,this.value);">
		<option value="all" >全部</option>
{{range .Rooms}}<option value="{{.}}" >{{.}}</option>{{end}}
	</select></b>
	</div>
	<div>
{{range .Records}}<div>[{{.Room}}] {{.Time.Format "2006-01-02 15:04:05"}} {{.Name}} 说：<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{{.Msg}}</div>{{end}}
	</div>
	<div>
	<a href="/history/{{.Room}}/s?p={{.LastPage}}&w={{.Word}}">上一页</a>
	<a href="/history/{{.Room}}/s?p={{.NextPage}}&w={{.Word}}">下一页</a>
	页码：<input type="text" size=4 value={{.Page}} id="pagenum" /><input type="button" onclick="gotoPage($('#pagenum').val(),null);" value="跳转">
	</div>
</div>
<script>
var currentRoom = "{{.Room}}";
//gotoPage p=页码，r=聊天室命/all/null
function gotoPage(p,r){
	if(r==null){
		r=currentRoom;
	}
	window.location.href="{{.Prefix}}/history/"+r+"/s?w={{.Word}}&p="+p;
}
function searchHistory(){
	var w  = $("#searchWord").val();
	if(w.length>0){
		window.location.href="{{.Prefix}}/history/{{.Room}}/s?w="+w;
	}
}

$($("#chatroom").val(currentRoom));
$($("#searchWord").val("{{.Word}}"));
</script>
</body>
</html>
